package com.jz.community.moduleauthorization.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Tony.Fan on 2018/3/21 16:56
 * <p>
 * 正则匹配工具类
 */
public class RegexUtils {

    private static String numberRegex = "[0-9]*";

    /**
     * 功能：判断字符串是否为数字
     */
    public static boolean isNumber(String str) {
        Pattern pattern = Pattern.compile(numberRegex);
        Matcher isNum = pattern.matcher(str);
        if (isNum.matches()) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 判断是否是手机号码
     *
     * @param index
     * @return
     */
    public static boolean isPhone(String index) {
        String telRex = "^(1[0-9])\\d{9}$";
        return index.matches(telRex);
    }
}
